<?php

class TendenciasController extends Zend_Controller_Action
{

    public function init()
    {
        /* Initialize action controller here */
    }

    public function indexAction()
    {
		
           Zend_Paginator::setDefaultItemCountPerPage(30);
        Zend_View_Helper_PaginationControl::setDefaultViewPartial('galeria/paginator.phtml');

		$portifolioModel = new Application_Model_Galerias();
		
		$galerias = $portifolioModel->fetchAll(
			$portifolioModel->select()->where('excluido = 0')
									->where('tipo = 0')
					);
		$this->view->galerias = $galerias;

		$paginator = Zend_Paginator::factory($this->view->galerias);

            $paginator->setCurrentPageNumber($this->_request->getParam('pagina'));

            $this->view->paginator = $paginator; 
    }

    public function visualizarAction()
    {
        $numprod = $this->_request->getParam('qtd');
        $gal = $this->_request->getParam('id');
        $this->view->qtd = $numprod;
		
        if(isset($numprod)){
           Zend_Paginator::setDefaultItemCountPerPage($numprod);
        }else{
           Zend_Paginator::setDefaultItemCountPerPage(30);
        }
        Zend_View_Helper_PaginationControl::setDefaultViewPartial('tendencias/paginator.phtml');

		$eventoModel = new Application_Model_Galeria();
		
		$fotos = $eventoModel->fetchAll(
			$eventoModel->select()->where('excluido = 0')
									->where('galeria = ?', $gal)
					);
		$this->view->produtos = $fotos;
		$this->view->id = $gal;

		$paginator = Zend_Paginator::factory($this->view->produtos);

            $paginator->setCurrentPageNumber($this->_request->getParam('pagina'));

            $this->view->paginator = $paginator; 
    }

}

